const express = require('express')
const app = express()
const port = 3000
const bodyParser = require('body-parser')
///访问静态文件
app.use(express.static('www'))

///访问上传的文件
app.use('/uploads', express.static('uploads'))

///解析body中间件
app.use(bodyParser.json({limit:'100mb'}));

//设置跨域访问
app.all('*',function(req,res,next) {
  res.header("Access-Control-Allow-Origin","*");///允许域名
  res.header('Access-Control-Allow-Methods','PUT,GET,POST,DELETE,OPTIONS');///允许请求方式
  res.header("Access-Control-Allow-Headers","X-Requested-With");///允许head
  res.header('Access-Control-Allow-Headers','token,content-type')///允许head
  next();
});

///调用wx
const wxRouter = require('./wx')
wxRouter(app)
///调用admin

const adminRouter = require('./admin')
adminRouter(app)

app.listen(port, () => {
  console.log(`Example app listening on port ${port}`)
})